#!/usr/bin/env python
# -*- coding:utf-8 -*-
from wsgiref.simple_server import make_server

def RunServer(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    url = environ['PATH_INFO']
    func_name = url.split('/')[1]
    import home

    is_exist = hasattr(home, func_name)
    if is_exist:    #去模块中检查，是否有指定函数,如果存在该函数，
        func = getattr(home, func_name)     #获取函数
        ret = func()
        return ret          #将函数返回值相应给请求者
    else:
        return '404 not found'

if __name__ == '__main__':
    httpd = make_server('', 8001, RunServer)
    print "Serving HTTP on port 8001..."
    httpd.serve_forever()